package com.neusoft.elmboot.converter;

import java.util.ArrayList;
import java.util.List;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import com.neusoft.elmboot.bean.Role;
import com.neusoft.elmboot.common.ElmException;

/**
 * 
 * @author chens
 *
 */
@Component("RoleStringListConverter")
public class RoleStringListConverter implements Converter<String, List<Role>> {

	@Override
	public List<Role> convert(String source) {
		if (source != null) {
			List<Role> list = new ArrayList<Role>();
			try {
				list.add(new Role(Integer.valueOf(source), null));
			} catch (RuntimeException e) {
				throw new ElmException("角色ID转换异常");
			}
			return list;
		}
		return null;
	}

}
